﻿using System;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {

        private void JLTCPWB02(DataSet db)
        {
            try
            {
                DataTable tbWBBST = db.Tables["WBBST"];  
                DataTable dtOutput = new DataTable();
                int idx = 1;
                #region======Title===========
                exAgent.SetCellValue(3, idx++, "花型号"); dtOutput.Columns.Add("WBBART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "小花号"); dtOutput.Columns.Add("WBBFARBE", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "小卷号"); dtOutput.Columns.Add("WBBPACKNR", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "格型"); dtOutput.Columns.Add("WBBDPART", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "色级"); dtOutput.Columns.Add("WBBTAX", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "数量（米）"); dtOutput.Columns.Add("WBBISTKLG", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "数量（码）"); dtOutput.Columns.Add("WBBISTKLGM", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "工号"); dtOutput.Columns.Add("WBBWARSCH", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "入库日期"); dtOutput.Columns.Add("WBBFLZZUGDAT", typeof(System.String));
                exAgent.SetCellValue(3, idx++, "卷号"); dtOutput.Columns.Add("WBBSTKNR", typeof(System.String)); 
                #endregion 
                dtOutput.Merge(tbWBBST, false, MissingSchemaAction.Ignore);  
               foreach (DataRow row in dtOutput.Rows)
                {
                   double lg= System.Convert.ToDouble(row["WBBISTKLG"].ToString())*0.001;
                   row["WBBISTKLG"] = Helper.RoundX(lg , 100);
                    row["WBBISTKLGM"] =Helper.RoundX(lg/0.9144,10); 
                }
                exAgent.DataTableToExcel(dtOutput, 4, 1);
                exAgent.SetCellValue(1, 1, 1);
               int count = dtOutput.Rows.Count; 
               exAgent.BatchConvert2Number(2, 6, count + 3, 7);
               exAgent.SetCellValue(1, 1, "成品细码单");
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }


        public DataTable tbWBBST { get; set; }
    }
}